//
//  WMFullscreenAd.h
//  AFNetworking
//
//  Created by zero on 2020/6/18.
//

#import <Foundation/Foundation.h>

#import "WMConfig.h"
#import "WMAdConfig.h"
#import "WMAnalytics.h"
#import "WMPlatformTool.h"

#import "WMBaseAdProtocol.h"

#import "NSObject+Property.h"

#import <SVProgressHUD/SVProgressHUD.h>

NS_ASSUME_NONNULL_BEGIN

@interface WMBaseAd : NSObject<WMBaseAdProtocol>

@property (nonatomic, strong) WMPlatformTool* platformTool;

@property (nonatomic, strong) NSMutableArray<NSMutableArray<NSObject *> *>* ads;

@property (nonatomic, strong) NSMutableArray<NSObject *>* tmpAds;

@property (nonatomic, strong) UIViewController* rootViewController;

@property (nonatomic, strong) NSMutableDictionary *timeDict;

// 播放广告的次数
@property (nonatomic, strong) NSMutableDictionary *playDict;


@property (nonatomic, copy) NSString* adTypeName;


@property (nonatomic, assign) NSUInteger startTime;

@property (nonatomic, assign) NSUInteger preloadIndex;

@property (nonatomic, assign) NSUInteger preloadCount;

@property (nonatomic, assign) NSUInteger localIndex;

@property (nonatomic, assign) NSUInteger thePlayingAdhash;


@property (nonatomic, assign) BOOL clicked;

@property (nonatomic, assign) BOOL localSuccessFlag;

@property (nonatomic, assign) BOOL isLocalAdFlag;


@property (nonatomic, assign) BOOL isLoading;


@property (nonatomic, copy) void(^logBblock)(NSString *log);


- (instancetype)initWithAdIdModel:(WMAdId *)adIdModel posId:(NSString *)posId;


- (BOOL)isAdAdvalid:(NSObject *)ad;

- (void)preloadAdWithPlan:(WMPlan *)plan;

- (void)peloadNextAdWithAdHash:(NSUInteger)hash;

- (void)preloadNoCacheAdWithPlans:(NSMutableArray<WMPlan *> *)plans posIds:(NSArray *)posIds;

- (BOOL)shouldStopLoadAd:(NSUInteger)preloadMaxCount;

- (BOOL)hasBasePriceInHierarchy:(NSMutableArray *)plans;

- (NSObject *)wm_getHasCacheAdWithPlan:(WMPlan *)plan;

- (NSArray *)noCacheAdIdsInHierarchy:(NSMutableArray<WMPlan *> *)plans;

- (NSObject *)getCurrentAd;

- (void)addCacheAd:(NSObject *)ad;

- (void)removeTheClosedAd:(NSObject *)ad isIgnorePrice:(BOOL)isIgnorePrice;

- (NSUInteger)numOfvalidAd;

- (NSUInteger)numOfNoBsePriceAd;


// 打点

- (void)logAdDidLoad:(NSObject *)ad;

- (void)logAd:(NSObject *)ad didFailWithError:(NSError *_Nullable)error;

- (void)logAdDidVisible:(NSObject *)ad;

- (void)logAdDidClick:(NSObject *)ad;

- (void)logAdWillShow:(NSObject *)ad;

@end

NS_ASSUME_NONNULL_END
